<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../css/mycss.css" />
<title>管理员页面</title>
</head>
<c:if test="${pass==null}">
	<c:redirect url="http://localhost:8080/SSMFrame/jsp/home.jsp" />
</c:if>
<c:if test="${pass.getName()!=priority.name}">
	<c:redirect url="http://localhost:8080/SSMFrame/jsp/home.jsp" />
</c:if>
<body >
	<table >
		<tr>
			<td width="220px">
				<div
					class="menu">

					<a href="http://localhost:8080/SSMFrame/jsp/home.jsp">首页</a><br />
					<br> <a href="http://localhost:8080/SSMFrame/jsp/BMI_Number.jsp">身高体重指数</a><br />
					<br> <a href="http://localhost:8080/SSMFrame/jsp/recipe.jsp">食谱分析</a><br />
					<br> <a
						href="http://localhost:8080/SSMFrame/jsp/energyCount.jsp">能量收支</a><br />
					<br> <a href="http://localhost:8080/SSMFrame/exit.do">退出登录</a>

				</div>
			</td>
			<td style="vertical-align:text-top ;text-align:center;width:300px">
				<h1>系统成员管理</h1>
				<form action="admin.do">
					<input type="submit" name="submit" value="search" /> <input
						type="text" name="name">
				</form><br>

				<div align="center">
					<c:set var="pagesize" value="10" scope="page" />
					<!--记录数 -->
					<c:set var="number" value="${result.size()}" scope="page" />

					<!-- 计算分页数 -->
					<c:set var="pagenumber" value="${param.start/pagesize+1}" />

					<table border="1" style="border-collapse: collapse; align: center">
						<tr>
							<th>姓名</th>
							<th>权限</th>
							<th>权限修改</th>
							<th>删除</th>
						</tr>
						<!--判断是否有信息  -->
						<!-- 如果类别为空  otherwise -->
						<c:choose>
							<c:when test="${empty result}">
								<tr>
									<td colspan="4" align="center">没有找到用户！</td>
								</tr>
							</c:when>
							<c:otherwise>
								<c:forEach items="${result}" var="row" begin="${param.start}"
									end="${param.start+pagesize-1}">
									<tr>
										<td>${row.name}</td>
										<td>${row.priority}</td>
										<td><a href="admin.do?submit=rise&name=${row.name}">升级</a></td>
										<td><a href="admin.do?submit=delete&name=${row.name}">删除</a></td>
									</tr>
								</c:forEach>
							</c:otherwise>
						</c:choose>
					</table>

					<!--分页  -->
					<c:choose>
						<c:when test="${param.start>9}">
							<a href="admin.jsp?start=${param.start-pagesize}">上一页</a>
						</c:when>
						<c:otherwise>
         首页
   </c:otherwise>
					</c:choose>

					<!-- 显示分页数 -->
					第<font color="red">${pagenumber}"</font>页

					<c:choose>
						<c:when test="${param.start+pagesize<number}">
							<a href="admin.jsp?start=${param.start+pagesize}">下一页</a>
						</c:when>
						<c:otherwise>
	尾页
   </c:otherwise>
					</c:choose>

					<!-- 显示记录数 -->
					共<font color="red">${number}</font>条记录 &nbsp;

				</div>
			</td>
		</tr>
	</table>
</body>
</html>